/**
 * 
 */
package com.mobile2you.nci.android.utils;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mobile2you.nci.android.R;
import com.mobile2you.nci.android.domain.Services;

/**
 * @author JBromo
 * 
 */
public class ListServicesAdapter extends BaseAdapter {

	List<Services> listcentres = new ArrayList<Services>();

	boolean express;

	class CentreItemView extends LinearLayout {
		TextView name;

		public CentreItemView(Context context, Services centres) {
			super(context);
			LayoutInflater.from(context).inflate(R.layout.centre_item_view,
					this, true);
			name = (TextView) findViewById(R.id.label_centre_item_name);
			name.setText(centres.getTitle());
		}

	}

	/**
	 * @param listNews
	 */
	public ListServicesAdapter(List<Services> listcentres, boolean express) {
		this.listcentres = listcentres;
		this.express = express;

	}

	@Override
	public int getCount() {
		return listcentres.size();
	}

	@Override
	public Object getItem(int position) {
		return listcentres.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Services centres = listcentres.get(position);
		CentreItemView centreItemView = null;
		if (convertView != null) {
			centreItemView = (CentreItemView) convertView;
			return centreItemView;
		}
		return new CentreItemView(parent.getContext(), centres);

	}
}
